package cn.xdf.controller;

import cn.xdf.entity.Goods;
import cn.xdf.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("/search")
    public String search(String searchVal, Model model){

        List<Goods> goodsList=goodsService.search(searchVal);//从搜索条件找到list
        model.addAttribute("goodsList",goodsList);
        model.addAttribute("searchVal",searchVal);


        return "/search.jsp";

    }

}
